<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<link rel="shortcut icon" href="https://winhc.oss-cn-shanghai.aliyuncs.com/webImg/whc.ico" type="image/x-icon">
	<script src="3rd/jquery-1.11.3.min.js"></script>
	<script src="im/js/request.js"></script>
	<title>赢火虫云信</title>
	<script>
		var arr = getQueryStringArgs();
		if(arr["token"]){//从mis入口登录进去
			//存放各个数据
			var token = arr["token"];
			var data = {
				"sign":token
			}
			$.ajax({
				url:requestUrl + "/firefly-login/login/open/login/mis",
				method:'get',
				cache:false,
				headers: {
					'Accept': "application/json; charset=utf-8",
					'appid': "WEB_SITE",
					'apiVersion': "1.0",
					'sessionId': "",
					'osType': "",
					'deviceId': "",
					'brand': "",
					'osVersion': "",
					'appVersion': ""
				},
				data:data,
				contentType: "application/json;charset=utf-8",
				dataType: "json",
				success:function(data,textStatus,jqXHR){
					if(data.isSuccess == "T"){
						var tempData = data.body;
						sessionStorage.setItem('uid', tempData.userIm.accId);
						sessionStorage.setItem('sdktoken', tempData.userIm.token);
						sessionStorage.setItem('userId',tempData.userIm.userId);
						sessionStorage.setItem('sessionId',tempData.sessionId);
						sessionStorage.setItem('iMmobileNo',tempData.mobileNo);
						sessionStorage.setItem('lawyerFirmName',tempData.userExt && tempData.userExt.lawfirmName)
					}else{
						// location.href="./im/login.html"
						location.href = websiteUrl;
					}
				},
				error:function(xhr,textStatus){
					console.log('失败返回=',xhr)
					// location.href="./im/login.html"
					location.href = websiteUrl;
				}
			})
		}else{//从网站进入

			// location.href="./im/login.html"
			//相同域名下可获取localstorage数据
			if(localStorage.getItem("operInfo")){
				//存储相关数据
				let infoData = JSON.parse(localStorage.getItem("operInfo"));
				sessionStorage.setItem('uid', infoData.userIm.accId);
				sessionStorage.setItem('sdktoken', infoData.userIm.token);
				sessionStorage.setItem('userId',infoData.userIm.userId);
				sessionStorage.setItem('sessionId',infoData.sessionId);
				sessionStorage.setItem('iMmobileNo',infoData.mobileNo);
				sessionStorage.setItem('lawyerFirmName',infoData.userExt && infoData.userExt.lawfirmName)
				setTimeout(function(){
					location.href="./im/main.html"+window.location.search
				},100);

			}

		}

		function getQueryStringArgs() {
			var qs = (location.search.length>0 ? location.search.substring(1):""),
			args = {},
			items = qs.length ? qs.split("&") : [],
			item = null,
			name = null,
			value = null,
			i=0,
			len = items.length;
			for(i=0;i<len;i++){
				if(items[i].indexOf("token=") != -1){
					name = "token";
					value = decodeURIComponent(items[i].replace("token=",""));//执行解码，因为中文字符串往往在传递时被编码过了
				}else{
					item = items[i].split("=");
					name = decodeURIComponent(item[0]);
					value = decodeURIComponent(item[1]);//执行解码，因为中文字符串往往在传递时被编码过了
				}
				
				if(name.length)
					args[name]=value;
			}
			return args;
		}
	</script>
</head>
<body>
	
</body>
</html>